package com.example.clocktime;

import java.util.ArrayList;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TimeTrackerAdapter extends BaseAdapter{

	private ArrayList<TimeRecord> times = new ArrayList<TimeRecord> ();
	
	public TimeTrackerAdapter(){
	
		times.add(new TimeRecord("38.23", "Feeling good!!"));
		times.add(new TimeRecord("49.01", "Tired.Needed more caffeine"));
		times.add(new TimeRecord("26.20", "I'm rocking it!"));
		times.add(new TimeRecord("29.42", "Lost some time on the hills, but pretty good."));
		
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return times.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return getItem(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView == null){
			LayoutInflater inflater = LayoutInflater.from(parent.getContext());
			convertView = inflater.inflate(R.layout.time_list_item, parent, false);
		}
		
		TimeRecord time = times.get(position);
		
		TextView timeTextView = (TextView) convertView.findViewById(R.id.time_view);
		TextView notesTextView = (TextView) convertView.findViewById(R.id.note_view);
		notesTextView.setText(time.getNotes());
		
		
		return convertView;
	}

}
